﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using KerriganMobile.MobileServiceWCF;
using KerriganMobile.Models;
using System.Diagnostics;

namespace KerriganMobile.Views
{
    public partial class AddMark : PhoneApplicationPage
    {
        public AddMarkVO vo;

        public AddMark()
        {
            InitializeComponent();
            vo = new AddMarkVO();
            DataContext = vo;
        }

        private void add_btn_Click(object sender, RoutedEventArgs e)
        {
            vo.markDC.Date = DateTime.Now;
            ApplicationManager.client.AddMarkCompleted += new EventHandler<AddMarkCompletedEventArgs>(client_AddMarkCompleted);
            ApplicationManager.client.AddMarkAsync(ApplicationManager.ID_CURRENT_SESSION, ApplicationManager.ID_CURRENT_CUSTOMER, vo.markDC);

        }

        void client_AddMarkCompleted(object sender, AddMarkCompletedEventArgs e)
        {
            if (e.Result)
            {
                ApplicationManager.changeURI(this, "CustomerList");
            }
            else {
                MessageBox.Show("Error!");
            
            }
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("Loaded Addmark");
        }
    }


    public class AddMarkVO {

        public AddMarkVO() {
            markDC = new CustomerEvaluationDC();
        }

        public CustomerEvaluationDC markDC { get; set; }

    }
}